package com.ruoyi.web.controller.server;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SysSupervise;
import com.ruoyi.system.service.ISysSuperviseService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 辅导教师Controller
 * 
 * @author ruoyi
 * @date 2025-04-21
 */
@RestController
@RequestMapping("/system/supervise")
public class SysSuperviseController extends BaseController
{
    @Autowired
    private ISysSuperviseService sysSuperviseService;

    /**
     * 查询辅导教师列表
     */
    @GetMapping("/list")
    public TableDataInfo list(SysSupervise sysSupervise)
    {
        startPage();
        List<SysSupervise> list = sysSuperviseService.selectSysSuperviseList(sysSupervise);
        return getDataTable(list);
    }

    /**
     * 导出辅导教师列表
     */
    @PreAuthorize("@ss.hasPermi('system:supervise:export')")
    @Log(title = "辅导教师", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysSupervise sysSupervise)
    {
        List<SysSupervise> list = sysSuperviseService.selectSysSuperviseList(sysSupervise);
        ExcelUtil<SysSupervise> util = new ExcelUtil<SysSupervise>(SysSupervise.class);
        util.exportExcel(response, list, "辅导教师数据");
    }

    /**
     * 获取辅导教师详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:supervise:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(sysSuperviseService.selectSysSuperviseById(id));
    }

    /**
     * 新增辅导教师
     */
    @PreAuthorize("@ss.hasPermi('system:supervise:add')")
    @Log(title = "辅导教师", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysSupervise sysSupervise)
    {
        return toAjax(sysSuperviseService.insertSysSupervise(sysSupervise));
    }

    /**
     * 修改辅导教师
     */
    @PreAuthorize("@ss.hasPermi('system:supervise:edit')")
    @Log(title = "辅导教师", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysSupervise sysSupervise)
    {
        return toAjax(sysSuperviseService.updateSysSupervise(sysSupervise));
    }

    /**
     * 删除辅导教师
     */
    @PreAuthorize("@ss.hasPermi('system:supervise:remove')")
    @Log(title = "辅导教师", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sysSuperviseService.deleteSysSuperviseByIds(ids));
    }
}
